package crawl;

import java.net.URI;

public enum Scheme
{
    FILE("file"), FTP("ftp"), HTTP("http"), OTHER("other");

    private String typeString;

    private Scheme(String scheme)
    {
        this.typeString = scheme;
    }

    @Override
    public String toString()
    {
        return this.typeString;
    }

    public static Scheme fromString(String scheme)
    {
        scheme = scheme.toLowerCase();
        if (scheme.equals("file"))
            return FILE;
        else if (scheme.equals("ftp"))
            return FTP;
        else if (scheme.equals("http") || scheme.equals("https"))
            return HTTP;
        else
            return OTHER;
    }

    public static Scheme fromURI(URI uri)
    {
        return fromString(uri.getScheme());
    }
}
